//////////////////////////////////////////////////////////////////////////
//	Name: CDXRenderWin32.h
//	Purpose: Creates and displays a "Render to Texture quad!"
//	Created: November 15, 2009
//////////////////////////////////////////////////////////////////////////

#pragma once


#include "CDXRenderWin32.h"

#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)


struct D3DVERTEX
{
	float fX;
	float fY;
	float fZ;
	DWORD dwColor;
};


class CDXRenderToTexture
{
	LPDIRECT3DTEXTURE9 m_pRenderTexture;
	LPDIRECT3DSURFACE9 m_pRenderSurface;
	LPDIRECT3DSURFACE9 m_pBackBuffer;
	D3DXMATRIX m_matProjection;
	D3DXMATRIX m_matOldProjection;
	CDXRenderWin32 *m_pDXRW32;
	LPDIRECT3DVERTEXBUFFER9 pQuadVB;

	CDXRenderToTexture()
	{
		m_pRenderTexture = NULL;
		m_pRenderSurface = NULL;
		m_pBackBuffer = NULL;
		pQuadVB = NULL;
	}

	friend class CDXRenderWin32;
	

	//////////////////////////////////////////////////////////////////////////
	//	Name: SetRenderState
	//	Purpose: Init the "render to texture"
	//	In: 
	//	Out:
	//	Return:	bool - true upon success
	//////////////////////////////////////////////////////////////////////////
	bool InitR2T();

	//////////////////////////////////////////////////////////////////////////
	//	Name: ShutDownR2T
	//	Purpose: kill the "render to texture"
	//	In: 
	//	Out:
	//	Return:	bool - true upon success
	//////////////////////////////////////////////////////////////////////////
	bool ShutDownR2T();

	//////////////////////////////////////////////////////////////////////////
	//	Name: StartR2T
	//	Purpose: Start the render to texture!! call this before u render anything
	//	In: 
	//	Out:
	//	Return:	void
	//////////////////////////////////////////////////////////////////////////
	void StartR2T();

	//////////////////////////////////////////////////////////////////////////
	//	Name: RenderPassR2T
	//	Purpose: Render the texture to the screen!! call this after you render the scene.
	//	In: matTranslation - i dunno about this
	//	Out:
	//	Return:	void
	//////////////////////////////////////////////////////////////////////////
	void RenderPassR2T(D3DMATRIX matTranslation);
};